{extend name="$layout"}
{block name="content"}  
<script type="text/javascript" src="/public/libs/jstree/jstree.js"></script>
<script type="text/javascript" src="/public/libs/jstree/jstree.checkbox.js"></script>
<script type="text/javascript" src="/public/libs/jstree/jstree.changed.js"></script>
<link rel="stylesheet" href="/public/libs/jstree/themes/default/style.css" /> 
 
<form class="form-horizontal" onsubmit="return save(this);" id="ajaxForm" action="" method="post" >
    <div class="form-group">
        <div class="col-sm-4">
            当前角色：{$role.name}
            <div id="meunlist"></div>
        </div>
    </div> 
    <div class="form-group">
        <div class="col-sm-4">
            <button class="btn btn-primary" type="submit">保存</button>   
            <input type="hidden" name="ids" id="ids" value="">      
            <input type="hidden" name="roleid" value="{$role.roleid}">                         
        </div>
    </div>
</form> 

<script type="text/javascript">
    $('#meunlist').jstree({
        "core": {
        	"check_callback": true,
        	'multiple': false,
        	"ui": {   
	            theme_name : "checkbox"    
	        },
            "data": {$ms}
        }, 
        plugins: ["checkbox"],
        "checkbox": {
            "three_state": true,//父子级别级联选择
            "tie_selection": false
        }
    });  
    function save(sender){ 
    	var str=''; 
        $("#meunlist .jstree-checked").each(function(){ 
            var $this = $(this);  
            var id=$this.attr("id").replace('_anchor',',').replace('j1_1','');
            if(id.length>0){
            	str=str+id; 
            } 
        });
        $("#ids").attr('value',str); 
        return app.submit(sender,'allot');
    }
</script>
{/block}
 